﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Model;
using Resources;
using Service;

public partial class GroupeSoftwareAdd : System.Web.UI.Page
{
    readonly ReferenceDataService _ReferenceDataService = new ReferenceDataService();
    readonly StockService _StockService = new StockService();
    private DirectService _DirectService = new DirectService();

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void bntValidate_Click(object sender, EventArgs e)
    {

        GroupeSoftware _groupeSoftware = new GroupeSoftware();
        if(txtGroupeSoftware.Text=="")
        {
            lblRequiredGroupeSoftware.Visible = true;
            lblMessageValidate.Text = ""; 
            return;

        }
        {
            IList list = new ArrayList();
            list = _StockService.GetGroupeSoftware();

            for (int i = 0; i < list.Count; i++)
            {
                if (((GroupeSoftware)list[i]).GroupeSoftwareLabel == txtGroupeSoftware.Text)
                {
                    lblRequiredGroupeSoftware.Visible = false;
                    lblMessage.Visible = true;
                    return;
                }
                lblMessage.Visible = false;
            }
        }
        _groupeSoftware.GroupeSoftwareId = 0;
        _groupeSoftware.GroupeSoftwareLabel = txtGroupeSoftware.Text;
        _groupeSoftware.Description = txtdescription.Text; 
        _ReferenceDataService.SaveGroupeSoftware(_groupeSoftware);
        lblRequiredGroupeSoftware.Visible = false;
        ClearControlAdd();
        lblMessageValidate.Text = Resource.MessageValidate; 
    }
    private void ClearControlAdd()
    {
        txtGroupeSoftware.Text = "";
        txtdescription.Text = "";
        lblMessageValidate.Text = "";
   
    }
    protected void bntCancel_Click(object sender, EventArgs e)
    {
        ClearControlAdd();
    }
}
